package com.example.basic;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class EventDialogFragment extends DialogFragment {
  public final static String EXTRA_MESSAGE = "com.example.basic.EventDialogFragment.EXTRA_MESSAGE";

  public static EventDialogFragment newInstance(String message) {
    Bundle args = new Bundle();
    args.putString(EXTRA_MESSAGE, message);

    EventDialogFragment fragment = new EventDialogFragment();
    fragment.setArguments(args);
    return fragment;
  }

  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    String message = getArguments().getString(EXTRA_MESSAGE);

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_event_title)
    .setMessage(message)
    .setPositiveButton(R.string.dialog_event_button_text, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int id) {
        // FIRE ZE MISSILES!
      }
    });
    // Create the AlertDialog object and return it
    return builder.create();
  }
}
